package com.zspringboot.demo.service.impl;

import com.zspringboot.demo.entity.SpecificContent;
import com.zspringboot.demo.entity.TitleContent;
import com.zspringboot.demo.mapper.SpecificContentMapper;
import com.zspringboot.demo.mapper.TitleContentMapper;
import com.zspringboot.demo.service.ISpecificContentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.swagger.models.auth.In;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;

/**
 * <p>
 * 项目具体内容 服务实现类
 * </p>
 *
 * @author laolang
 * @since 2024-03-12
 */
@Service
public class SpecificContentServiceImpl extends ServiceImpl<SpecificContentMapper, SpecificContent> implements ISpecificContentService {

    @Resource
    SpecificContentMapper specificContentMapper;
    @Resource
    TitleContentMapper titleContentMapper;
    @Override
    public AtomicReference<String> getSpecific(Integer id,List<Integer> value1) {

        // 将 项目对应关系存入数据库
        // 先删除绑定关系
        titleContentMapper.deleteSCId(id);



        AtomicReference<String> strings = new AtomicReference<>("");
        value1.forEach(i->{
            // 将对应关系存入数据库
            titleContentMapper.insert(new TitleContent(id,i));
            strings.updateAndGet(v -> v + specificContentMapper.selectById(i).getContent());
        });
        return strings;
    }
}
